home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4255 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: news.umbc.edu!not-for-mail
  2. From: schlein@umbc.edu (Jonas J. Schlein)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: HELP..Need to find why atan2 gives..
  5. Date: 2 Feb 1996 17:15:59 -0500
  6. Organization: University of Maryland Baltimore County
  7. Message-ID: <4eu2ev$ab9@umbc9.umbc.edu>
  8. References: <Pine.OSF.3.91.960201012731.27628B-100000@reno.WPI.EDU>
  9. NNTP-Posting-Host: umbc9.umbc.edu
  10. NNTP-Posting-User: schlein
  11.  
  12. Jose Andres Giraldez  <vittohue@wpi.edu> wrote:
  13. |> I need to find why atan2 gives a number smaller than -180 and greater 
  14. |> than 180.
  15. |> ??????????
  16. |> 
  17. |> /*It works on BIGWPI.wpi.edu*/
  18. |> #include <stdio.h>
  19. |> #include <float.h>
  20. |> #include <math.h>
  21. |> #include "/cs/cs1005/problems/problem2/problem2.h"
  22.  
  23. We don't have problem2.h so your code can't be compiled on other machines
  24. unless the definitions from this file are made available.
  25.  
  26. |> int main ()
  27. |> {
  28. |>   int Pi=3.14159, count, n_rows, n_columns;
  29.  
  30. What do you intend here? Pi is declared as an int, but 3.14159 is clearly not.
  31.  
  32. [lots of code deleted]
  33.  
  34. |>   /*Convert theta from radians to degrees*/
  35. |>   {
  36. |>     for (count = 0; count<N_MEAS; count++)
  37. |>       {
  38. |>         degrees[count] =  (double) ((theta[count] * 180)/Pi)+Pi;
  39.  
  40. Obviously your value of Pi (in this case 3) is going to throw off the
  41. calculations.
  42.  
  43. [Lots more code deleted]
  44.  
  45. |>   Pi=3.14159;
  46.  
  47. You can do this assignment all day and get no more accurate results. Since Pi
  48. is an integer it simply cannot store 3.14159 as you have entered it.
  49.  
  50. Can't forget 'return (0);'!
  51. |> }
  52. -- 
  53. "If it wasn't for C, we would be using BASI, PASAL, and OBOL."
  54.  
  55. Jonas J. Schlein  (schlein@gl.umbc.edu)
  56.